#include <log.h>
#include <time.h>

void test_hour()
{
	struct log_t* log = log_init(ELogRotator_Hour, ELogLevel_Debug, "testlog", 0);
	if(!log)
		exit(-1);
	
	time_t now = time(NULL);
	time_t start = now;
	while(1)
	{
		sleep(1);
		time_t cur = time(NULL);
		if(cur > now + 10)
		{
			LOG_DEBUG(log, cur, "%d", (int)cur);
			now = cur;
		}

		if(now - start > 60 * 60)
			break;
	}
	
	log_release(log);
}

void test_size()
{
	struct log_t* log = log_init(ELogRotator_Size, ELogLevel_Debug, "testlog", 1024);
	if(!log)
		exit(-1);
	
	int loop = 1000;
	while(1)
	{
		sleep(1);
		time_t cur = time(NULL);
		LOG_DEBUG(log, cur, "%d", (int)cur);
		loop --;
		if(0 == loop)
			break;
	}
	
	log_release(log);
}

int main()
{
	test_size();
	return 0;
}

